<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>用户列表</title>
    <link rel="stylesheet" href="assets/css/amazeui.css">
</head>
<body>

<div class="am-progress">
    <div class="am-progress-bar am-progress-bar-secondary" style="width: 10%"></div>
</div>


<a href="addstu.php" class="am-btn am-btn-warning" >添加学生</a>
<table class="am-table am-table-bordered am-table-striped am-table-compact">
    <thead>
    <tr>
        <th>名字</th>
        <th>学号</th>
        <th>性别</th>
        <th>年龄</th>
        <th>电话</th>
    </tr>
    </thead>
    <tbody>

    <?php

    foreach ($students as $stu){

    ?>
    <tr>
        <td><?php echo $stu['Stud_name']?></td>
        <td><?php echo $stu['Stud_id']?></td>
        <td><?php echo $stu['Stud_sex']?></td>
        <td><?php echo $stu['Birth_date']?></td>
        <td><?php echo $stu['Mobile']?></td>
        <td>
            <a class="am-btn am-btn-success" href="index.php?action=student&func=findStudent&id=<?php echo $stu['Stud_id']?>">编辑</a>
            <a class="am-btn am-btn-danger" href="index.php?action=student&func=del&id=<?php echo $stu['Stud_id']?>">删除</a></td>
    </tr>

    <?php
       }
    ?>

    </tbody>
</table>

<ul class="am-pagination am-pagination-centered">

    当前第<?php echo $page; ?>页,共<?php echo $count_page; ?>页

    <?php


    if ($page != 1){
        $ss = $page - 1;
        echo "<li><a href=\"index.php?action=student&func=lists&page=1\">首页</a></li>";
        echo "<li><a href=\"index.php?action=student&func=lists&page={$ss} \">&laquo;</a></li> ";

    }else{
        echo "<li class=\"am-disabled\" ><a href=\"#\" >首页</a></li> ";
        echo "<li class=\"am-disabled\" ><a href=\"#\" >&laquo;</a></li> ";
    }

    $num1=0;
    for($i=$page-2;$i<=$page+2+$num1;$i++)
    {

        if($i==-1||$i==0)
        {
            $num1++;
            continue;
        }
        if($i==$count_page+1||$i==$count_page+2)
        {
            continue;
        }
        if($i==$count_page-3)
        {
            if($page==$count_page-1)
            {
                $num=$count_page-3;
                echo "<li><a href=\"index.php?action=student&func=lists&page=$num\">$num</a>";
            }
        }
        if($i==$count_page-2)
        {
            if($page==$count_page)
            {
                $num=$count_page-3;
                echo "<li><a href=\"index.php?action=student&func=lists&page=$num\">$num</a>";
                $num--;
                echo "<li><a href=\"index.php?action=student&func=lists&page=$num\">$num</a>";
            }
        }
            if($page == $i){
                echo "<li  class=\"am-active\" ><a href=\"index.php?action=student&func=lists&page=$i\">$i</a></li>";
                //
            }else {
                echo "<li><a href=\"index.php?action=student&func=lists&page=$i\">$i</a></li>";
            }
    }

    if ($page < $count_page){
        $ss = $page + 1;
        echo "<li><a href=\"index.php?action=student&func=lists&page={$ss} \">&raquo;</a></li> ";
        echo "<li><a href=\"index.php?action=student&func=lists&page=$count_page\">尾页</a></li>";
    }else{
        echo "<li class=\"am-disabled\" ><a href=\"#\" >&raquo;</a></li> ";
        echo "<li class=\"am-disabled\" ><a href=\"#\" >尾页</a></li> ";

    }
     ?>
</ul>




</body>
</html>
